import React, { useEffect, useRef } from 'react'
import * as echarts from 'echarts';
const MyEcharts: React.FC = ({ option }) => {
    const box = useRef(null)
    useEffect(() => {
        const myChart = echarts.init(box.current)
        myChart.setOption(option)
        const resize = () => {
            myChart.resize()
        }
        window.addEventListener('resize', resize)
        return () => {
            window.removeEventListener('resize', resize)
        }
    }, [])
    return <div ref={box} style={{ width: "100%", height: "100%" }}></div>
}

export default MyEcharts
